package com.example.administrator.myrxjavademo.net;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by Administrator on 2017\8\17 0017.
 */

public class NetClient {
    private static NetClient sInstance;
    private Retrofit mRetrofit;

    private NetClient() {
        mRetrofit = new Retrofit.Builder()
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .baseUrl("http://api.yyougo.com/")
                .build();
    }

    public static NetClient getInstance() {
        if (sInstance == null) {
            synchronized (NetClient.class) {
                if (sInstance == null) {
                    sInstance = new NetClient();
                }
            }
        }
        return sInstance;
    }

    public <T> T createApi(Class<T> T) {
        return mRetrofit.create(T);
    }
}
